#include "link_stack.h"


Stack LinkStackCreate()
{
    Stack head = (Stack)malloc(sizeof(StackNode));
    head->next = NULL;
    head->data = -1;
    return head;
}

void LinkStackPush(Stack stack,ElemType data)
{
    Stack s = (Stack)malloc(sizeof(StackNode));
    s->data = data;
    s->next = stack->next;
    stack->next = s;

}

void LinkStackTraverse(Stack stack)
{
    Stack temp = stack;
    while(temp->next != NULL)
    {
        temp = temp->next;
        printf("%d\n",temp->data);
    }
}

ElemType LinkStackPop(Stack stack)
{
    Stack s = stack->next;
    stack->next = s->next;
    ElemType data = s->data;
    s->next = NULL;
    free(s);
    return data;
}
